import { Schema } from 'mongoose';
import { IToolCall } from '../types/IToolCall';

export const ToolCallSchema = new Schema<IToolCall>({
  toolCallId: { type: String, required: true },
  toolName: { type: String, required: true },
  parameters: { type: Schema.Types.Mixed },
  status: {
    type: String,
    enum: ['pending', 'executing', 'completed', 'failed', 'cancelled'],
    default: 'pending'
  },
  startTime: { type: Date, required: true },
  endTime: { type: Date },
  executionTime: { type: Number, min: 0 },
  result: {
    success: { type: Boolean },
    data: { type: Schema.Types.Mixed },
    error: {
      code: { type: String },
      message: { type: String },
      details: { type: Schema.Types.Mixed }
    },
    metadata: { type: Schema.Types.Mixed }
  },
  retryCount: { type: Number, default: 0, min: 0 },
  maxRetries: { type: Number, default: 0, min: 0 }
}, { _id: false });
